--
-- Rotor module interface definition
--

--
-- Local refrences to global objects
--
local Rotor = _G.Rotor

local RotorPlugin = {}

--
-- Answer plugin name
--
-- arguments:
--      none
--  returns:
--      module name <string>
--
function RotorPlugin:Name()
    return self.plugin_name
end

--
-- Initialize plugin
--
-- arguments:
--      options<table> - table of module options (persist between logons if Rotor:rememberPluginOptions(plugin, options) is called)
-- return: none
--
function RotorPlugin:Init(options)
    -- do nothing by default
end

--
-- Update function. Called when frame OnUpdate event occured.
--
-- arguments:
--      elapsed<float> - time in seconds since last call to Update
-- return:
--      none
--
function RotorPlugin:Update(elapsed)
end

--
-- called when graphical scale changed
function RotorPlugin:ScaleChanged(new_scale)
end

--
-- called when graphical alpha changed
--
function RotorPlugin:AlphaChanged(new_alpha)
end

--
-- Called when spells auras and resources fully updated
--
function RotorPlugin:SpellsAurasAndResourcesUpdated()
end

--
-- Called when rotor shown/hidden.
--
function RotorPlugin:MainInterfaceVisibilityChanged(main_interface_visible)
end

function RotorPlugin:CurrentModuleFinalized()
end

function RotorPlugin:NewModuleSelected()
end

--
-- Notify module about target changed.
--
-- arguments:
--      old_target_guid - GUID of previous valid target
-- return:
--      none
function RotorPlugin:TargetChanged(old_target_guid)
end

--
-- Notify module when unit is entering or leaving combat
--
-- arugments:
--      none
-- return:
--      none
--
function RotorPlugin:CombatStateChanged()
end

--
-- Handle commands from command line. called when /rr opt ... is executed
--
-- arguments:
--      cmd_line<string> - text after '/rr opt'
-- return:
--      true - module reinitialization required, false otherwise
--
function RotorPlugin:HandleCommandLine(cmd_line)
    Rotor:print('plugin "'..self:Name()..'" does not have options')
    return false
end

----------------------------------------
--
-- Create and register new plugin
--
function Rotor:NewPlugin(plugin_name)
    if not plugin_name then
        error('no plugin name given')
    end

    if self.plugins and self.plugins[plugin_name] then
        error('plugin "'..plugin_name..'" alredy exists')
    end

    local plugin = setmetatable({plugin_name = plugin_name}, {__index = RotorPlugin})

    if not self.plugins then
        self.plugins = {}
    end
    self.plugins[plugin_name] = plugin
    return plugin
end
